﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Drawing;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

public partial class Mod_FlatManger_frm_Worker : System.Web.UI.Page
{
    public void ChangPage(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        DataSet dst = cls_Property.SetOrGetCorporationDataSet;

        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            string strKey = ((LinkButton)sender).CommandName;
            int intPageIndex = this.dgrdResult.CurrentPageIndex;
            int intPageCounts = this.dgrdResult.PageCount;

            if (strKey == "0")
            {
                intPageIndex = 0;
            }
            else if (strKey == "1")
            {
                if (intPageIndex > 0) intPageIndex -= 1;
            }
            else if (strKey == "2")
            {
                if (intPageIndex < intPageCounts - 1) intPageIndex += 1;
            }
            else
            {
                intPageIndex = intPageCounts - 1;
            }

            this.BindWorkerByDataView(dst, intPageIndex);
        }
    }

    public void AddWorkerInfo(object sender, EventArgs e)
    {
        ClsWorkerDAL cls_Worker = new ClsWorkerDAL();
       // ImageButton ibtn = (ImageButton)sender;
       // int intIndex = Int32.Parse(ibtn.CommandArgument);
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        string strUserIDD = cls_Property.SetOrGetUserID;
        if (strUserIDD != "")
        {
            string strWk_ID = this.txt1.Value.Trim();
            string strWk_Name = this.txt2.Text.Trim();
            string strWk_Sex = this.dropSex.SelectedItem.Value;
            //DateTime strWk_Birth = Convert.ToDateTime(this.txtAddBirthday.Text.Trim());
            //string strWk_Birth = this.txtAddBirthday.Text.Trim();
            DateTime strWk_Birth = Convert.ToDateTime(this.txtAddBirthday.Text.Trim());
            string txtAddSid = this.txtAddSid.Text.Trim();
            string dropZz = this.dropZz.SelectedItem.Value;
            string dropMarry = this.dropMarry.SelectedItem.Value;
            string dropNation = this.dropNation.SelectedItem.Value;
            string txtAddDept = this.txtAddDept.Text;
            string txtAddInDate = this.txtAddInDate.Text;
            string dropDegree = this.dropDegree.SelectedItem.Value;
            string dropJz = this.dropJz.SelectedItem.Value;
            string txtAddDuty = this.txtAddDuty.Text.Trim();
            string txtWordClass = this.txtWordClass.Text.Trim();
            string dropWkType = this.dropWkType.SelectedItem.Value;
            string txtAddress = this.txtAddress.Text.Trim();
            string txtAddPost = this.txtAddPost.Text.Trim();
            string txtAddTel = this.txtAddTel.Text.Trim();
            string txtAddMobile = this.txtAddMobile.Text.Trim();
            string txtAddEmail = this.txtAddEmail.Text.Trim();
            string txtAddWebSite = this.txtAddWebSite.Text.Trim();
            string txtAddSchool = this.txtAddSchool.Text.Trim();
            string txtAddMajor = this.txtAddMajor.Text.Trim();
            string txtAddRemark = this.txtAddRemark.Text.Trim();


            try
            {
                Boolean bolIsCussee = cls_Worker.AddWorker(strWk_ID, strWk_Name, strWk_Sex, strWk_Birth, txtAddSid,
                    dropZz, dropMarry, dropNation, txtAddDept, txtAddInDate, dropDegree, dropJz, "m", "n", txtAddDuty, txtWordClass,
                 dropWkType, txtAddress, txtAddPost, txtAddTel, txtAddMobile, txtAddEmail, txtAddWebSite, txtAddSchool,
                 txtAddMajor, true, strUserIDD, true, txtAddRemark);


                if (bolIsCussee)
                {
                    this.GetWorkers();//重新绑定

                    StringBuilder strJs = new StringBuilder();
                    strJs.Append("<script>document.getElementById('trAdd').style.display='block';");
                    strJs.Append("var dt=new Date();var y=dt.getYear();var m=dt.getMonth();var d=dt.getDay();var h=dt.getHours();var mi=dt.getMinutes();var s=dt.getSeconds();var ct=y+''+m+''+d+''+h+''+mi+''+s;");
                    strJs.Append("document.getElementById('txt1').value = 'C_'+ct;");
                    strJs.Append("document.getElementById('txt2').value = '';");
                    strJs.Append("document.getElementById('" + this.txt2.ClientID + "').select();");
                    strJs.Append("document.getElementById('" + this.txt2.ClientID + "').focus()</script>");
                    this.lblJs.Text = strJs.ToString();
                }
                else
                {
                    this.lblJs.Text = "<script>alert('新增员工信息失败，请重试！')</script>";
                }
            }
            catch
            {
                this.lblJs.Text = "<script>alert('新增员工信息失败！')</script>";
            }
        }
        else
        {
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    public void UpDateWorkerInfo(object sender, EventArgs e)
    {
        ClsWorkerDAL cls_Worker = new ClsWorkerDAL();
        ImageButton ibtn = (ImageButton)sender;
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        string strUserIDD = cls_Property.SetOrGetUserID;
        int intCommandName = Int32.Parse(ibtn.CommandName);
        if (strUserIDD != "")
        {
            if (intCommandName == 1)//确认
            {
                int intCount = this.dgrdResult.Items.Count;

                for (int i = 0; i < intCount; i++)
                {
                    CheckBox chkBox = (CheckBox)this.dgrdResult.Items[i].FindControl("chkSelect");

                    if (chkBox.Checked)
                    {
                        TextBox txtBox = (TextBox)this.dgrdResult.Items[i].FindControl("wk_id");

                        Boolean bolIsCussee = cls_Worker.AuditStatWorker(txtBox.Text.Trim(), intCommandName, strUserIDD);

                        if (!bolIsCussee)
                        {
                            this.lblJs.Text = "<script>alert('确认员工信息失败，请重试！')</script>";
                        }
                    }
                }

                this.GetWorkers();//重新绑定
            }
            else//取消确认，编辑，取消编辑，保存编辑
            {
                int intIndex = Int32.Parse(ibtn.CommandArgument);

                CheckBox chk = (CheckBox)this.dgrdResult.Items[intIndex].FindControl("chkSelect");
                TextBox wk_id = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_id");
                TextBox wk_name = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_name");
                DropDownList wk_sex = (DropDownList)this.dgrdResult.Items[intIndex].FindControl("wk_sex");
                TextBox remark = (TextBox)this.dgrdResult.Items[intIndex].FindControl("remark");
                ImageButton ibtnEdit = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnEdit");
                ImageButton ibtnCan = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnCan");
                ImageButton ibtnSer = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnSer");
                ImageButton ibtnOAudit = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnOAudit");
                DropDownList wk_zz = (DropDownList)this.dgrdResult.Items[intIndex].FindControl("wk_zz");//
                DropDownList wk_marry = (DropDownList)this.dgrdResult.Items[intIndex].FindControl("wk_marry");//
                DropDownList wk_nation = (DropDownList)this.dgrdResult.Items[intIndex].FindControl("wk_nation");//
                DropDownList wk_degree = (DropDownList)this.dgrdResult.Items[intIndex].FindControl("wk_degree");//
                DropDownList wk_jz = (DropDownList)this.dgrdResult.Items[intIndex].FindControl("wk_jz");//
                DropDownList wk_type = (DropDownList)this.dgrdResult.Items[intIndex].FindControl("wk_type");//
                TextBox wk_zzz = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_zzz");//
                TextBox wk_marryy = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_marryy");//
                TextBox wk_nationn = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_nationn");//
                TextBox wk_degreee = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_degreee");//
                TextBox wk_jzz = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_jzz");//
                TextBox wk_typee = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_typee");//
                TextBox wk_sexx = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_sexx");
                TextBox wk_sid = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_sid");
                TextBox dt_id = (TextBox)this.dgrdResult.Items[intIndex].FindControl("dt_id");
                TextBox wc_id = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wc_id");
                TextBox wk_Address = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_address");
                TextBox wk_AddPost = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_post");
                TextBox wk_AddTel = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_tel");
                TextBox wk_AddMobile = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_mobile");
                TextBox wk_AddEmail = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_email");
                TextBox wk_AddWebSite = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_webSite");
                TextBox wk_AddSchool = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_school");
                TextBox wk_AddMajor = (TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_major");
                CuTextSelectBox dp_id = (CuTextSelectBox)this.dgrdResult.Items[intIndex].FindControl("dp_id");
                CuTextSelectBox wk_birthday = (CuTextSelectBox)this.dgrdResult.Items[intIndex].FindControl("wk_birthday");
                CuTextSelectBox in_date = (CuTextSelectBox)this.dgrdResult.Items[intIndex].FindControl("in_date");

                if (intCommandName == 0)//取消确认
                {
                    Boolean bolIsCussee = cls_Worker.AuditStatWorker(wk_id.Text.Trim(), intCommandName, strUserIDD);

                    if (bolIsCussee)
                    {
                        this.GetWorkers();//重新绑定
                    }
                    else
                    {
                        this.lblJs.Text = "<script>alert('取消确认员工信息失败，请重试！')</script>";
                    }
                }
                else if (intCommandName == 2)//编辑
                {
                    chk.Visible = ibtnEdit.Visible = wk_sexx.Visible = wk_zzz.Visible = wk_marryy.Visible = wk_nationn.Visible = wk_degreee.Visible = wk_jzz.Visible = wk_typee.Visible = false;
                    ibtnCan.Visible = ibtnSer.Visible = wk_sex.Visible = wk_zz.Visible = wk_marry.Visible = wk_nation.Visible = wk_degree.Visible = wk_jz.Visible = wk_type.Visible = true;
                    wk_name.ReadOnly = remark.ReadOnly = wk_birthday.ReadOnly = wk_sid.ReadOnly = dt_id.ReadOnly = wc_id.ReadOnly = dp_id.ReadOnly = wk_birthday.ReadOnly = in_date.ReadOnly = false;
                    wk_Address.ReadOnly = wk_AddPost.ReadOnly = wk_AddTel.ReadOnly = wk_AddMobile.ReadOnly = wk_AddEmail.ReadOnly = wk_AddWebSite.ReadOnly = wk_AddSchool.ReadOnly = wk_AddMajor.ReadOnly = false;
                    wk_Address.BorderWidth = wk_AddPost.BorderWidth = wk_AddTel.BorderWidth = wk_AddMobile.BorderWidth = wk_AddEmail.BorderWidth = wk_AddWebSite.BorderWidth = wk_AddSchool.BorderWidth = wk_AddMajor.BorderWidth = 1;
                    wk_sex.Enabled = true; 
                    wk_name.BorderWidth = wk_sex.BorderWidth = wk_sid.BorderWidth = remark.BorderWidth = dt_id.BorderWidth = wc_id.BorderWidth = 1;

                    //让第一个文本框获取焦点
                    this.lblJs.Text = "<script>document.getElementById('" + wk_name.ClientID + "').select();document.getElementById('" + wk_name.ClientID + "').focus()</script>";
                }
                else if (intCommandName == 3)//取消编辑
                {
                    chk.Visible = ibtnEdit.Visible = wk_sex.Visible = wk_zzz.Visible = wk_marryy.Visible = wk_nationn.Visible = wk_degreee.Visible = wk_jzz.Visible = wk_typee.Visible = true;
                    ibtnCan.Visible = ibtnSer.Visible = wk_sex.Visible = wk_zz.Visible = wk_marry.Visible = wk_nation.Visible = wk_degree.Visible = wk_jz.Visible = wk_type.Visible = false;
                    wk_name.ReadOnly = wk_sex.Enabled = remark.ReadOnly = txt2.ReadOnly = wk_sid.ReadOnly = dt_id.ReadOnly = wc_id.ReadOnly = dp_id.ReadOnly = wk_birthday.ReadOnly = in_date.ReadOnly = true;
                    wk_Address.BorderWidth = wk_AddPost.BorderWidth = wk_AddTel.BorderWidth = wk_AddMobile.BorderWidth = wk_AddEmail.BorderWidth = wk_AddWebSite.BorderWidth = wk_AddSchool.BorderWidth = wk_AddMajor.BorderWidth = 0;
                    txtAddress.ReadOnly = txtAddPost.ReadOnly = txtAddTel.ReadOnly = txtAddMobile.ReadOnly = txtAddEmail.ReadOnly = txtAddWebSite.ReadOnly = txtAddSchool.ReadOnly = txtAddMajor.ReadOnly = true;
                    wk_name.BorderWidth = wk_sex.BorderWidth = wk_sid.BorderWidth = remark.BorderWidth = dt_id.BorderWidth = wc_id.BorderWidth = 0;
                    this.lblJs.Text = "";
                    this.GetWorkers();//重新绑定
                }
                else//保存编辑
                {
                    try
                    {
                        Boolean bolIsCussee = cls_Worker.UpDateWorker(wk_id.Text.Trim(), wk_name.Text.Trim(), wk_sex.SelectedItem.Value, wk_birthday.Text.Trim(), wk_sid.Text.Trim(),
                            wk_zz.SelectedItem.Value, wk_marry.SelectedItem.Value, wk_nation.SelectedItem.Value,
                            dp_id.Text.Trim(), in_date.Text.Trim(), wk_degree.SelectedItem.Value, wk_jz.SelectedItem.Value, wk_type.Text.Trim(), wc_id.Text.Trim(), dt_id.Text.Trim(),

                            wk_Address.Text.Trim(), wk_AddPost.Text.Trim(), wk_AddTel.Text.Trim(), wk_AddMobile.Text.Trim(), wk_AddEmail.Text.Trim(), wk_AddWebSite.Text.Trim(),
                            wk_AddSchool.Text.Trim(), wk_AddMajor.Text.Trim(), remark.Text.Trim(), true);

                        if (bolIsCussee)
                        {
                            this.lblJs.Text = "";
                            this.GetWorkers();//重新绑定
                        }
                        else
                        {
                            this.lblJs.Text = "<script>alert('修改员工信息失败，请重试！')</script>";
                        }
                    }
                    catch
                    {
                        this.lblJs.Text = "<script>alert('请输入数字类型的员工汇率！')</script>";
                    }
                }
            }
        }
        else
        {
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    public void AuditWorker(object sender, ImageClickEventArgs e)
    {
        ClsWorkerDAL cls_Worker = new ClsWorkerDAL();
        int intCommand = Int32.Parse(((ImageButton)sender).CommandName);
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        string strUserIDD = cls_Property.SetOrGetUserID;
        if (strUserIDD != "")
        {
            if (intCommand == 0)//取消确认(不可批量)
            {
                int intIndex = Int32.Parse(((ImageButton)sender).CommandArgument);
                string strDp_ID = ((TextBox)this.dgrdResult.Items[intIndex].FindControl("wk_id")).Text.Trim();

                Boolean bolIsCussee = cls_Worker.AuditStatWorker(strDp_ID, intCommand, strUserIDD);

                if (!bolIsCussee)
                {
                    this.lblJs.Text = "<script>alert('抱歉！取消确认员工信息失败，请重试。')</script>";
                }
            }
            else//确认(可批量)
            {
                int intCount = this.dgrdResult.Items.Count;

                for (int i = 0; i < intCount; i++)
                {
                    CheckBox chkBox = (CheckBox)this.dgrdResult.Items[i].FindControl("chkSelect");

                    if (chkBox.Checked)
                    {
                        TextBox txtBox = (TextBox)this.dgrdResult.Items[i].FindControl("wk_id");

                        Boolean bolIsCussee = cls_Worker.AuditStatWorker(txtBox.Text.Trim(), intCommand, strUserIDD);

                        if (!bolIsCussee)
                        {
                            this.lblJs.Text = "<script>alert('抱歉！确认员工信息失败，请重试。')</script>";
                        }
                    }
                }
            }

            //重新绑定
            this.GetWorkers();
        }
        else
        {
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    private void GetWorkers()
    {        
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        string strUserID = cls_Property.SetOrGetUserID;

        ClsWorkerDAL cls_Worker = new ClsWorkerDAL();
        DataSet dst = cls_Worker.GetWorkers();

        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            cls_Property.SetOrGetCorporationDataSet = dst;

            this.BindWorkerByDataView(dst, 0);
        }
        else
        {
            this.lblRsCounts.Text = "共0条记录";
            this.lblPageCounts.Text = "共0页";
            this.lblCurrPage.Text = "当前第0页";
            this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = this.lbtnNext.Enabled = this.lbtnEnd.Enabled = this.txtGo.Enabled = false;
            this.lblRsCounts.ForeColor = this.lblPageCounts.ForeColor = this.lblCurrPage.ForeColor = this.lblGoTxt1.ForeColor = this.lblGoTxt2.ForeColor = Color.FromArgb(172, 168, 153);
        }
    }

    private void BindWorkerByDataView(DataSet dst, int CurrPageIndex)
    {
        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            this.dgrdResult.CurrentPageIndex = CurrPageIndex;
            this.dgrdResult.DataSource = dst;
            this.dgrdResult.DataBind();

            this.lblRsCounts.Text = "共" + dst.Tables[0].Rows.Count + "条记录";
            this.lblPageCounts.Text = "共" + this.dgrdResult.PageCount + "页";
            this.lblCurrPage.Text = "当前第" + (this.dgrdResult.CurrentPageIndex + 1) + "页";
            this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = this.lbtnNext.Enabled = this.lbtnEnd.Enabled = this.txtGo.Enabled = true;
            this.lblRsCounts.ForeColor = this.lblPageCounts.ForeColor = this.lblCurrPage.ForeColor = this.lblGoTxt1.ForeColor = this.lblGoTxt2.ForeColor = Color.FromArgb(78, 78, 78);

            if (this.dgrdResult.PageCount == 1)
            {
                this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = this.lbtnNext.Enabled = this.lbtnEnd.Enabled = this.txtGo.Enabled = false;
                this.lblGoTxt1.ForeColor = this.lblGoTxt2.ForeColor = Color.FromArgb(172, 168, 153);
            }
            else if (this.dgrdResult.CurrentPageIndex == this.dgrdResult.PageCount - 1)
            {
                this.lbtnNext.Enabled = this.lbtnEnd.Enabled = false;
            }
            else if (this.dgrdResult.CurrentPageIndex == 0)
            {
                this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = false;
            }
        }
    }

    private void ControlButtonVisible(string UserLogID, string CurrPageID)
    {
        ClsMenuDAL cls_Menu = new ClsMenuDAL();
        DataSet dst = cls_Menu.GetCurrUserButtonPopedom(UserLogID, CurrPageID);

        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            int intCount = dst.Tables[0].Rows.Count - 1;

            for (int i = intCount; i >= 0; i--)
            {
                int intButtonID = Int32.Parse(dst.Tables[0].Rows[i][2].ToString());

                switch (intButtonID)
                {
                    case 0:
                        this.panAdd.Visible = true;
                        break;
                    case 1:
                        this.hidButtonEdit.Value = intButtonID.ToString();
                        break;
                    case 2:
                        this.panDelete.Visible = true;
                        break;
                    case 3:
                        this.lbtnDelete1.Enabled = true;
                        break;
                    case 4:
                        this.panAudit.Visible = true;
                        break;
                    case 5:
                        this.hidButtonOAudit.Value = intButtonID.ToString();
                        break;
                    case 6:
                        this.panRef.Visible = true;
                        break;
                    case 7:
                        this.panSearch.Visible = true;
                        break;
                    case 20:
                        this.panPrint.Visible = true;
                        break;
                }
            }
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        string strUserID = cls_Property.SetOrGetUserID;

        if (strUserID != "")
        {
            if (!IsPostBack)
            {
                ////////////////按钮权限控制 Begin /////////////////////////
                string strCurrPageID = this.Page.Request.Params["PageID"];
                this.ControlButtonVisible(strUserID, strCurrPageID);
                //////////////////////  End ///////////////////////////////

                this.GetWorkers();
            }
            else
            {
                this.lblJs.Text = "";//清空JS脚本
            }

            this.ibtnDelete0.Attributes.Add("onClick", "return confirm('您真的要作废所选的项吗？');");
            this.lbtnDelete0.Attributes.Add("onClick", "return confirm('您真的要作废所选的项吗？');");
            this.lbtnDelete1.Attributes.Add("onClick", "return confirm('彻底作废将无法恢复数据。您真的要作废所选的项吗？');");
        }
        else
        {
            //ClsMenuDAL cls_Menu = new ClsMenuDAL();
            //string strMessage = cls_Menu.GetSystemCode("1", "00", this.txt1.Text.Trim(), 15);//取消当前系统编码
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    protected void DeleteWorkerInfo(int CommandName)
    {
        ClsWorkerDAL cls_Worker = new ClsWorkerDAL();
        int intCount = this.dgrdResult.Items.Count;

        if (CommandName == 1 || CommandName == -1)
        {
            //int intCount = this.dgrdResult.Items.Count;

            for (int i = 0; i < intCount; i++)
            {
                CheckBox chkBox = (CheckBox)this.dgrdResult.Items[i].FindControl("chkSelect");

                if (chkBox.Checked)
                {
                    TextBox txtBox = (TextBox)this.dgrdResult.Items[i].FindControl("wk_id");

                    Boolean bolIsCussee = cls_Worker.DeleteWorker(txtBox.Text.Trim(), CommandName);

                    if (!bolIsCussee)
                    {
                        this.lblJs.Text = "<script>alert('作废员工信息失败，请重试！')</script>";
                    }
                }
            }
        }

        //for (int i = 0; i < intCount; i++)
        //{
        //    CheckBox chkBox = (CheckBox)this.dgrdResult.Items[i].FindControl("chkSelect");

        //    if (chkBox.Checked)
        //    {
        //        TextBox txtBox = (TextBox)this.dgrdResult.Items[i].FindControl("wk_id");

        //        Boolean bolIsCussee = cls_Worker.DeleteWorker(txtBox.Text.Trim());

        //        if (!bolIsCussee)
        //        {
        //            this.lblJs.Text = "<script>alert('抱歉！作废员工信息失败，请重试。')</script>";
        //        }
        //    }
        //}

        //重新绑定
        this.GetWorkers();
    }

    protected void ibtnRefresh_Click(object sender, ImageClickEventArgs e)
    {
        this.GetWorkers();
    }

    protected void ibtnSearch_Click(object sender, ImageClickEventArgs e)
    {
        string strKey = this.txtKey.Text.Trim();

        if (strKey != "" && strKey != "查询关键字")
        {
            ClsWorkerDAL cls_Worker = new ClsWorkerDAL();
            DataSet dst = cls_Worker.SearchWorkers(strKey);

            if (dst != null && dst.Tables[0].Rows.Count > 0)
            {
                ClsPropertyDAL cls_Property = new ClsPropertyDAL();
                cls_Property.SetOrGetCorporationDataSet = dst;

                this.BindWorkerByDataView(dst, 0);
            }
            else
            {
                this.lblJs.Text = "<script>alert('抱歉！搜索结果为空。')</script>";
            }
        }
        else
        {
            this.lblJs.Text = "<script>alert('抱歉！请输入查询关键字。')</script>";
        }
    }

    protected void txtGo_TextChanged(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        DataSet dst = cls_Property.SetOrGetCorporationDataSet;

        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            string strIndex = this.txtGo.Text.Trim();
            this.txtGo.Text = String.Empty;

            if (strIndex != "")
            {
                try
                {
                    int intIndex = Int32.Parse(strIndex) - 1;

                    if (intIndex >= 0 && intIndex < this.dgrdResult.PageCount)
                    {
                        this.BindWorkerByDataView(dst, intIndex);
                    }
                    else
                    {
                        this.lblJs.Text = "<script>alert('抱歉！跳转页码只能在有效的页数内。')</script>";
                    }
                }
                catch
                {
                    this.lblJs.Text = "<script>alert('抱歉！跳转页码只能为数字。')</script>";
                }
            }
            else
            {
                this.lblJs.Text = "<script>alert('抱歉！跳转页码不能为空。')</script>";
            }
        }
    }

    protected void dgrdResult_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemIndex != -1)
        {   bool sex, zz;
            string strIs_audit = e.Item.Cells[1].Text.Trim();
            string strIs_sex = e.Item.Cells[2].Text.Trim();
            string strzz = e.Item.Cells[3].Text.Trim();
            string wk_marry = e.Item.Cells[4].Text.Trim();
            string wk_nation = e.Item.Cells[5].Text.Trim();
            string wk_degree = e.Item.Cells[6].Text.Trim();
            string wk_jz = e.Item.Cells[7].Text.Trim();
            string wk_type = e.Item.Cells[8].Text.Trim();
            if(strIs_sex=="M") sex=true; else sex=false;
            if (strzz == "0") zz = true; else  zz = false;
            CheckBox chkbox = (CheckBox)e.Item.FindControl("chkSelect");
            TextBox remark = (TextBox)e.Item.FindControl("remark");
            ImageButton ibtnEdit = (ImageButton)e.Item.FindControl("ibtnEdit");
            ImageButton ibtnCan = (ImageButton)e.Item.FindControl("ibtnCan");
            ImageButton ibtnSer = (ImageButton)e.Item.FindControl("ibtnSer");
            ImageButton ibtnOAudit = (ImageButton)e.Item.FindControl("ibtnOAudit");
            System.Web.UI.WebControls.Image is_audit = (System.Web.UI.WebControls.Image)e.Item.FindControl("is_audit");
            TextBox dp_statut = (TextBox)e.Item.FindControl("wk_sexx");
            TextBox dp_zzz = (TextBox)e.Item.FindControl("wk_zzz");
            TextBox wk_marryy = (TextBox)e.Item.FindControl("wk_marryy");
            TextBox wk_typee = (TextBox)e.Item.FindControl("wk_typee");
            TextBox wk_jzz = (TextBox)e.Item.FindControl("wk_jzz");
            TextBox wk_nationn = (TextBox)e.Item.FindControl("wk_nationn");
            TextBox wk_degreee = (TextBox)e.Item.FindControl("wk_degreee");
            DropDownList dp_statu = (DropDownList)e.Item.FindControl("wk_sex");
            DropDownList dp_zz = (DropDownList)e.Item.FindControl("wk_zz");
            DropDownList wk_typeee = (DropDownList)e.Item.FindControl("wk_type");
            DropDownList wk_marryyy = (DropDownList)e.Item.FindControl("wk_marry");
            DropDownList wk_nationnn = (DropDownList)e.Item.FindControl("wk_nation");
            DropDownList wk_degreeee = (DropDownList)e.Item.FindControl("wk_degree");
            DropDownList wk_jzzz = (DropDownList)e.Item.FindControl("wk_jz");
            dp_statu.SelectedIndex = (sex) ? 0 : 1;
            dp_zz.SelectedIndex = (zz) ? 0 : 1;
            wk_marryyy.SelectedIndex = int.Parse(wk_marry);
            wk_nationnn.SelectedIndex = int.Parse(wk_nation);
            wk_typeee.SelectedIndex = int.Parse(wk_type);
            wk_jzzz.SelectedIndex = int.Parse(wk_jz);
            dp_statut.Text = dp_statut.ToolTip = dp_statu.SelectedItem.Text;
            dp_zzz.Text = dp_zzz.ToolTip = dp_zz.SelectedItem.Text;
            wk_nationn.Text = wk_nationn.ToolTip = wk_nationnn.SelectedItem.Text;
            wk_marryy.Text = wk_marryy.ToolTip = wk_marryyy.SelectedItem.Text;
            wk_jzz.Text = wk_jzz.ToolTip = wk_jzzz.SelectedItem.Text;
            wk_typee.Text = wk_typee.ToolTip = wk_typeee.SelectedItem.Text;
            wk_degreee.Text = wk_degreee.ToolTip = wk_degreeee.SelectedItem.Text;
             //修改按回车提交
            if (remark.ReadOnly)
            {
                remark.Attributes.Add("onkeydown", "if(event.keyCode == 13){document.getElementById('" + ibtnSer.ClientID + "').click();}");
            }

            string strButtonEdit = this.hidButtonEdit.Value;
            string strButtonOAudit = this.hidButtonOAudit.Value;

            if (strIs_audit == "False")
            {
                if (strButtonEdit.Trim() == "1")
                {
                    if (this.panAudit.Visible || this.panDelete.Visible)
                    {
                        chkbox.Visible = true;
                    }

                    ibtnEdit.Visible = true;
                }
                else if (this.panAudit.Visible || this.panDelete.Visible)
                {
                    chkbox.Visible = true;
                }

                //chkbox.Visible = ibtnEdit.Visible = true;
                //ibtnOAudit.Visible = ibtnCan.Visible = ibtnSer.Visible = false;
                //is_audit.ImageUrl = "../App_Images/ico/6.gif";
            }
            else
            {
                ibtnOAudit.Visible = true;

                if (strButtonOAudit.Trim() != "5")
                {
                    ibtnOAudit.Enabled = false;
                    ibtnOAudit.ImageUrl = "../App_Images/ico/17.gif";
                }

                //ibtnOAudit.Visible = true;
                //chkbox.Visible = ibtnEdit.Visible = ibtnCan.Visible = ibtnSer.Visible = false;
                //is_audit.ImageUrl = "../App_Images/ico/7.gif";
            }
        }
    }

    public void lbtnDelete_Click(object sender, EventArgs e)
    {
        int intCommandName = Int32.Parse(((LinkButton)sender).CommandName);

        this.DeleteWorkerInfo(intCommandName);
    }

    protected void ibtnDelete0_Click(object sender, ImageClickEventArgs e)
    {
        int intCommandName = Int32.Parse(((ImageButton)sender).CommandName);

        this.DeleteWorkerInfo(intCommandName);
    }

    protected void ibtnPrint_Click(object sender, ImageClickEventArgs e)
    {
        this.lblJs.Text = "<script>var win = window.open('../Mod_ReportManage/frm_PrintPage.aspx?ReportUrl=','','top=0, left=0, toolbar=no, menubar=no,scrollbars=no, resizable=yes,location=no, status=no');";
        this.lblJs.Text += "win.moveTo(0,0); win.resizeTo(screen.availWidth,screen.availHeight);</script>";
    }
}
